package com.hdsx.restful.support;


import java.util.HashMap;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.hdsx.ao.dao.AoDao;
import com.hdsx.restful.base.DBSwitch;

public class DaoSupport{
	private Log log=LogFactory.getLog(DaoSupport.class);
	private static DaoSupport instance;
	
	private static Map<String,AoDao> observers=new HashMap<String,AoDao>();
	
	public static boolean flog=false;
	
	private String sdeHost;
	private String mapDataDir;
	public String getMapDataDir() {
		return mapDataDir;
	}
	private DaoSupport(){
		try {
			/*InputStream is = getClass().getResourceAsStream("/application.properties");
			Properties dbProps = new Properties();
			dbProps.load(is);
			sdeHost   = dbProps.getProperty("jdbc.sde");
			mapDataDir=dbProps.getProperty("hdsx.mapdatadir");*/
		} catch (Exception e) {
			log.info("数据库连接配置文件出错");
			e.printStackTrace();
		}
	}
	public static synchronized DaoSupport getInstance(){
		if(instance==null)
		{
			return new DaoSupport();
		}
		return instance;
	}
	/**
     * 注册观察者对象
     * @param observer    观察者对象
     */
    public static void attach(String key,AoDao value){
    	
    	observers.put(key, value);
        System.out.println("Attached an observer");
    }

	public static AoDao getDaoTemp()
	{
		return observers.get(DBSwitch.GISDBTEMP);
	}
	
	public static AoDao getDaoPublish(){
		
		return observers.get(DBSwitch.GISDB);
	}
	public String getSdeHost(){
		return sdeHost;
	}

}
